#ifndef CROSS_H
#define CROSS_H
#include<string>
namespace WEMS
{
#define Real double
struct CrossFactor
{
    Real area;//面积
    Real width;//过水宽度
    Real radius;//水力半径
};
struct CrossVar
{
    Real wl; //waterlevel
    Real flow;//discharge
    Real vel;//velocity

};
class Cross
{
public:
    Cross(){};
    Cross(const std::string&v):name(v)
    {}
    CrossFactor&getFactor(int flag){return flag?hyd:hyd_temp;}
    Real& getArea(int flag){return flag?hyd.area:hyd_temp.area; }
    Real& getWidth(int flag){return flag?hyd.width:hyd_temp.width;}
    Real& getRadius(int flag){return flag?hyd.radius:hyd_temp.radius;}
    void setArea(Real v,int flag){getArea(flag)=v;}
    void setWidth(Real v,int flag){getWidth(flag)=v;}
    void setRadius(Real v,int flag){getRadius(flag)=v;}

    std::string getName(){return name;}
    void setName(const std::string&v){name=v;}

    int getIndex(int flag){
        switch (flag)
        { 
        case 1:return id_reach;
        case 2:return id_reach_sub;
        default:return id;
        }
    }
    void setIndex(int v,int flag)
    {
        switch(flag)
        {
            case 1:id_reach=v;break;
            case 2:id_reach_sub=v;break;  
            default:id=v;break;
        }
    }
private:
    std::string name;//ID
    CrossFactor hyd; //水力要素
    CrossFactor hyd_temp;//迭代过程中的水力要素

    int id;         //自身索引
    int id_reach;   //所属河道索引
    int id_reach_sub;//所属河道内部的索引 
};

}
#endif // CROSS_H